/**
 * 
 */
package com.teamall.web.xtgl.common;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import com.teamall.core.spring.context.SpringApplicationContextHolder;
import com.teamall.framework.exception.BaseAppException;
import com.teamall.framework.log.LogManager;
import com.teamall.web.fpgz.db.po.CodeVillageInfoPO;
import com.teamall.web.fpgz.service.ICodeVillageInfoService;
import com.teamall.web.fpgz.service.impl.CodeVillageInfoServiceImpl;
import com.teamall.web.sys.db.po.DataDictPO;
import com.teamall.web.sys.service.impl.DataDictServiceImpl;

/**
 * <Description>数据字典等静态数据 <br>
 * 
 * @author pan.xiaobo<br>
 * @version 1.0<br>
 * @taskId <br>
 * @CreateDate 2017年8月17日 <br>
 * @since V1.0<br>
 * @see com.teamall.web.xtgl.common <br>
 */

public class StaticDataUtil {
    private static final LogManager logger = LogManager
            .getLogger(StaticDataUtil.class);

    // 性别
    public static Map<String, Integer> genderNameMap = new LinkedHashMap<String, Integer>();

    // 与户主关系
    public static Map<String, Integer> masterRelNameMap = new LinkedHashMap<String, Integer>();

    // 民族
    public static Map<String, Integer> nationNameMap = new LinkedHashMap<String, Integer>();

    // 文化程度
    public static Map<String, Integer> educationLevelNameMap = new LinkedHashMap<String, Integer>();

    // 在校生状况
    public static Map<String, Integer> studentStateNameMap = new LinkedHashMap<String, Integer>();

    // 健康状况
    public static Map<String, Integer> healthStateNameMap = new LinkedHashMap<String, Integer>();

    // 劳动技能
    public static Map<String, Integer> workSkillNameMap = new LinkedHashMap<String, Integer>();

    // 务工状况
    public static Map<String, Integer> workStateNameMap = new LinkedHashMap<String, Integer>();

    // 是否参加新型农村合作医疗
    public static Map<String, Integer> isNrcmsNameMap = new LinkedHashMap<String, Integer>();

    // 是否参加大病保
    public static Map<String, Integer> isInsuranceNameMap = new LinkedHashMap<String, Integer>();

    // 是否参加新型农村社会养老保险
    public static Map<String, Integer> isEndowmentNameMap = new LinkedHashMap<String, Integer>();

    // 是否参加城镇职工基本养老保险
    public static Map<String, Integer> isCityEndowmentNameMap = new LinkedHashMap<String, Integer>();

    // 脱贫属性
    public static Map<String, Integer> povertyStateNameMap = new LinkedHashMap<String, Integer>();

    // 贫困户属性
    public static Map<String, Integer> povertyAttrNameMap = new LinkedHashMap<String, Integer>();

    // 主要致贫原因
    public static Map<String, Integer> mainReasonNameMap = new LinkedHashMap<String, Integer>();

    // 行政村
    public static Map<String, Integer> villageInfoMap = new LinkedHashMap<String, Integer>();

    private DataDictServiceImpl dataDictService;

    private ICodeVillageInfoService codeVillageInfoService;

    public void initDataDictMap() throws BaseAppException {
        logger.debug("initDataDictMap...");
        dataDictService = SpringApplicationContextHolder
                .getBean(DataDictServiceImpl.class);
        codeVillageInfoService = SpringApplicationContextHolder
                .getBean(CodeVillageInfoServiceImpl.class);
        List<DataDictPO> allDataDict = dataDictService.qryAll();
        List<CodeVillageInfoPO> allVillageInfo = codeVillageInfoService
                .qryAll();

        isNrcmsNameMap.put("是", 1);
        isNrcmsNameMap.put("否", 0);

        isInsuranceNameMap.put("是", 1);
        isInsuranceNameMap.put("否", 0);

        isEndowmentNameMap.put("是", 1);
        isEndowmentNameMap.put("否", 0);

        isCityEndowmentNameMap.put("是", 1);
        isCityEndowmentNameMap.put("否", 0);

        for (DataDictPO dataDict : allDataDict) {
            if (4 == dataDict.getDataGroup()) {
                genderNameMap
                        .put(dataDict.getDataName(), dataDict.getDataKey());
            }

            if (205 == dataDict.getDataGroup()) {
                masterRelNameMap.put(dataDict.getDataName(),
                        dataDict.getDataKey());
            }

            if (206 == dataDict.getDataGroup()) {
                nationNameMap
                        .put(dataDict.getDataName(), dataDict.getDataKey());
            }
            if (208 == dataDict.getDataGroup()) {
                educationLevelNameMap.put(dataDict.getDataName(),
                        dataDict.getDataKey());
            }
            if (209 == dataDict.getDataGroup()) {
                studentStateNameMap.put(dataDict.getDataName(),
                        dataDict.getDataKey());
            }
            if (210 == dataDict.getDataGroup()) {
                healthStateNameMap.put(dataDict.getDataName(),
                        dataDict.getDataKey());
            }
            if (211 == dataDict.getDataGroup()) {
                workSkillNameMap.put(dataDict.getDataName(),
                        dataDict.getDataKey());
            }
            if (212 == dataDict.getDataGroup()) {
                workStateNameMap.put(dataDict.getDataName(),
                        dataDict.getDataKey());
            }
            if (202 == dataDict.getDataGroup()) {
                povertyStateNameMap.put(dataDict.getDataName(),
                        dataDict.getDataKey());
            }
            if (200 == dataDict.getDataGroup()) {
                povertyAttrNameMap.put(dataDict.getDataName(),
                        dataDict.getDataKey());
            }
            if (201 == dataDict.getDataGroup()) {
                mainReasonNameMap.put(dataDict.getDataName(),
                        dataDict.getDataKey());
            }
        }

        for (CodeVillageInfoPO vilageInfo : allVillageInfo) {
            villageInfoMap.put(vilageInfo.getVillageName(),
                    vilageInfo.getVillageId());
        }
    }

}
